﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;
using MySql.EntityFrameworkCore.Metadata;

#nullable disable

namespace SCRS.Db.Migrations
{
    public partial class v103 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterDatabase()
                .Annotation("MySQL:Charset", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SYS_ACCOUNT",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false, comment: "账号ID")
                        .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
                    NAME = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false, comment: "姓名"),
                    USERNAME = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false, comment: "用户名"),
                    PASSWORD = table.Column<string>(type: "Char(32)", maxLength: 32, nullable: false, comment: "密码"),
                    ROLE = table.Column<string>(type: "json", nullable: false, comment: "角色"),
                    FACE_CODE = table.Column<string>(type: "json", nullable: true, comment: "人脸识别编码")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SYS_ACCOUNT", x => x.ID);
                })
                .Annotation("MySQL:Charset", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SYS_COMMODITY",
                columns: table => new
                {
                    ID = table.Column<string>(type: "varchar(255)", nullable: false),
                    NAME = table.Column<string>(type: "longtext", nullable: true),
                    PURCHASE_PRICE = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
                    RETAIL_PRICE = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
                    STOCK = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SYS_COMMODITY", x => x.ID);
                })
                .Annotation("MySQL:Charset", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SYS_LOGGER_RECORD",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "char(36)", nullable: false),
                    OPERATION_TIME = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    OPERATOR = table.Column<int>(type: "int", nullable: false),
                    OPERATION_TYPE = table.Column<string>(type: "longtext", nullable: false),
                    CONTENT = table.Column<string>(type: "json", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SYS_LOGGER_RECORD", x => x.ID);
                })
                .Annotation("MySQL:Charset", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SYS_ORDER_DETAIL",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
                    ORDER_ID = table.Column<string>(type: "longtext", nullable: false),
                    COMMODITY_ID = table.Column<string>(type: "longtext", nullable: false),
                    COMMODITY_NUM = table.Column<int>(type: "int", nullable: false),
                    COMMODITY_PRICE = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
                    PAYMENT = table.Column<decimal>(type: "decimal(18,2)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SYS_ORDER_DETAIL", x => x.ID);
                })
                .Annotation("MySQL:Charset", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SYS_ORDER_INFO",
                columns: table => new
                {
                    ID = table.Column<string>(type: "varchar(255)", nullable: false),
                    TOTAL_PRICE = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
                    ORDER_TIME = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    CASHIER = table.Column<int>(type: "int", nullable: false),
                    VIP_CARD_ID = table.Column<string>(type: "longtext", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SYS_ORDER_INFO", x => x.ID);
                })
                .Annotation("MySQL:Charset", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SYS_STORAGE_RECORD",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "char(36)", nullable: false),
                    COMMODITY_ID = table.Column<string>(type: "longtext", nullable: false),
                    STORAGE_NUM = table.Column<int>(type: "int", nullable: false),
                    STORAGE_TIME = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    STORAGE_OPERATOR = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SYS_STORAGE_RECORD", x => x.ID);
                })
                .Annotation("MySQL:Charset", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SYS_VIP_CARD",
                columns: table => new
                {
                    ID = table.Column<string>(type: "varchar(255)", nullable: false),
                    NAME = table.Column<string>(type: "longtext", nullable: false),
                    PHONE = table.Column<string>(type: "longtext", nullable: false),
                    BALANCE = table.Column<decimal>(type: "decimal(18,2)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SYS_VIP_CARD", x => x.ID);
                })
                .Annotation("MySQL:Charset", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SYS_VIP_PAY_RECORD",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "char(36)", nullable: false),
                    VIP_CARD_ID = table.Column<string>(type: "longtext", nullable: false),
                    PAY_AMOUNT = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
                    PAY_TIME = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    OPERATOR = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SYS_VIP_PAY_RECORD", x => x.ID);
                })
                .Annotation("MySQL:Charset", "utf8mb4");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "SYS_ACCOUNT");

            migrationBuilder.DropTable(
                name: "SYS_COMMODITY");

            migrationBuilder.DropTable(
                name: "SYS_LOGGER_RECORD");

            migrationBuilder.DropTable(
                name: "SYS_ORDER_DETAIL");

            migrationBuilder.DropTable(
                name: "SYS_ORDER_INFO");

            migrationBuilder.DropTable(
                name: "SYS_STORAGE_RECORD");

            migrationBuilder.DropTable(
                name: "SYS_VIP_CARD");

            migrationBuilder.DropTable(
                name: "SYS_VIP_PAY_RECORD");
        }
    }
}
